package com.example.mountain;

import android.R.layout;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.Messenger;
import android.os.RemoteException;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.LinearLayout;

public class Mosquito extends Activity implements OnClickListener {
	LinearLayout la;

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.mosquito);

		la = (LinearLayout) findViewById(R.id.layoutmo);
		findViewById(R.id.media_start).setOnClickListener(this);
		findViewById(R.id.media_stop).setOnClickListener(this);
		findViewById(R.id.media_timer).setOnClickListener(this);
	}

	public void onClick(View v) {
		BackThread thread = new BackThread();

		switch (v.getId()) {
		case R.id.media_start:
			startService(new Intent(this, MusicService.class));
			la.setBackgroundResource(R.drawable.lillmo);
			break;
		case R.id.media_stop:
			stopService(new Intent(this, MusicService.class));
			la.setBackgroundResource(R.drawable.mo);
			break;
		case R.id.media_timer:
			startService(new Intent(this, MusicService.class));
			la.setBackgroundResource(R.drawable.lillmo);
			thread.start();
			break;
		}
	}

	class BackThread extends Thread {

		public void run() {
			while (true) {
				try {
					Thread.sleep(7200000);
					stopService(new Intent(Mosquito.this, MusicService.class));

				} catch (InterruptedException e) {

					e.printStackTrace();
				}
			}
		}
	}

}